<?php
/////////////////////////////////////////////////////////////////////////////
// @author lee99 <lee99.com@gmail.com> Sat Mar 15 11:32:05 GMT 2008
//+----------------------------------------------------------
//说明
//+----------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////


class MapsAction extends PublicAction{


	public function index(){
		$this->display();
	}


	public function ajaxlist(){

		$list=D("Maps");

		$order=!empty($_REQUEST["order"])?$_REQUEST["order"]:$list->getPk(); //排序字段,默认为"Pk"
		$sortd=!empty($_REQUEST["sort"])?$_REQUEST["sort"]:"asc"; //排序顺序,默认为"asc"
		$orderBy=$order." ".$sortd;//组合排序条件

		$feilds='id,labelid,type,screen_w,click_x,click_y,uptime,create_on,update_on,id';

		$condition=Array();//搜索的条件
		//$condition['title']=array('like',"a%");//高级搜索过滤

		if(!empty($_REQUEST['searchkey'])){
			//搜索相关
			$searchkey=$_REQUEST["searchkey"];
			$searchtype=!empty($_REQUEST['searchtype'])?$_REQUEST['searchtype']:'OR';//默认的公共搜索条件为OR

			$this->assign("searchkey",$_REQUEST["searchkey"]);//显示关键字
			$this->assign("searchurl",$_SERVER["REQUEST_URI"]);//当前的URL
			$this->assign("searchtype",$_REQUEST["searchtype"]);//当前的搜索类型

			$ser_c=array('like',"%$searchkey%");//公共的过滤条件
			$condition['id,labelid,type,screen_w,click_x,click_y,create_on,update_on,id']=array($ser_c,$ser_c,$ser_c,$ser_c,$ser_c,$ser_c,$ser_c,$ser_c,id,$searchtype);//模糊搜索关键字全局过滤
		}


		$count= $list->count($condition);//获取分页总数量
		$p= new ajaxpage($count);
		$page=$p->ajaxshow();//显示分页
		$this->assign("page",$page);//显示分页
		$limit=$p->firstRow.",".$p->listRows;//设定分面的大小

		$limit=($limit==",")?'':$limit;//分页的大小

		$list=$list
		->where($condition)
		->field($feilds)
		->order($orderBy)
		->limit($limit)
		->findAll();

		$this->assign("list",$list);

		$this->display();

	}






	public function insert(){
		$list=D("Maps");
		$data=$_REQUEST;

		/*
		if(!empty($_FILES)) {
		$file= $this->_upload();//如果有文件上传 上传附件
		foreach ($file as $key=>$value){
		$data[$key]=$value['savename'];
		}
		}
		*/

		if($list->create($data)) {
			if($list->add($data)){
				$this->success('数据增加成功！');
			}else{
				$this->error('数据增加错误！');
			}
		}else{
			$this->error($list->getError());
		}

	}















	public function view(){
		$result=D("Maps");
		$list=$result->getById($_GET['id']);
		$this->assign('list',$list);
		$this->assign("id",$list["id"]);
		$this->assign("labelid",$list["labelid"]);
		$this->assign("type",$list["type"]);
		$this->assign("screen_w",$list["screen_w"]);
		$this->assign("click_x",$list["click_x"]);
		$this->assign("click_y",$list["click_y"]);
		$this->assign("uptime",$list["uptime"]);
		$this->assign("create_on",$list["create_on"]);
		$this->assign("update_on",$list["update_on"]);

		$this->display();
	}




	public function add(){
		$this->display();
	}



}
?>